import util from '@ohos.util';

class Base64 {
    private static base64 = null
    private static textDecoder = null

    private static init() {
        this.base64 = new util.Base64
        this.textDecoder = new util.TextDecoder("utf-8", { ignoreBOM: true })

    }

    public static decode(raw: string) {
        if(this.base64 == null || this.textDecoder == null) {
            this.init()
        }
        return this.textDecoder.decode(this.base64.decodeSync(raw))
    }
}

export default Base64